import json
from typing import Union

var1: list = [1, 2, 3]

var2 = 2  # type:int

var3 = json.loads('{"name":"John", "age":20}')


def add(x: Union[int, float], y: int) -> Union[int, float]:
    """

    :param x: 入参的类型
    :param y: 入参的类型
    :return: -> 表示要返回的结果,使用Union可以返回多个类型的值
    """
    return x + y


# 指定里面的类型为int或float
my_list: list[Union[int, float]] = [10, 20, 30, 23.8]

# 指定key为str,value为int和str
my_dict: dict[str, Union[int, str]] = {"name": "John", "age": 20}
